package cn.jhz.learn.blog.vo.article.query.page;

import cn.jhz.learn.blog.vo.PageView;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Optional;

@Setter
@Getter
@ToString
public class ArticlePageView extends PageView {

    //TODO：min
    @Length(min = 0, max = 15, message = "博客名无效!")
    private String blog_name;

    @Min(value = 1, message = "无效分支id!")
    private Integer subfield_id;

    @NotNull(message = "类型为null!")
    @Min(value = 0, message = "无效类型!")
    @Max(value = 1, message = "无效类型!")
    private Byte original;

    @NotNull(message = "排序方式为null!")
    @Min(value = 0, message = "无效排序方式!")
    @Max(value = 2, message = "无效排序方式!")
    private Byte sort;

    /**
     * 需要自行确保参数得到校验
     * @return
     */
    public Optional<String> getBlog_name() {
        return Optional.ofNullable(blog_name);
    }

    public Optional<Integer> getSubfield_id() {
        return Optional.ofNullable(subfield_id);
    }
}
